package br.com.toscano.gobra.view;

import javax.inject.Inject;
import br.gov.frameworkdemoiselle.annotation.PreviousView;
import br.gov.frameworkdemoiselle.stereotype.ViewController;
import br.gov.frameworkdemoiselle.template.AbstractEditPageBean;
import br.gov.frameworkdemoiselle.transaction.Transactional;
import br.com.toscano.gobra.business.EstadoBC;
import br.com.toscano.gobra.domain.Despesa;
import br.com.toscano.gobra.domain.Estado;

@ViewController
@PreviousView("./estado_list.jsf")
public class EstadoEditMB extends AbstractEditPageBean<Estado, String> {

	private static final long serialVersionUID = 1L;

	@Inject
	private EstadoBC estadoBC;
	
	@Override
	@Transactional
	public String delete() {
		this.estadoBC.delete(getId());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String insert() {
		this.estadoBC.insert(getBean());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String update() {
		this.estadoBC.update(getBean());
		return getPreviousView();
	}
	

	@Override
	protected Estado handleLoad(String id) {
		setBean(this.estadoBC.load(id));
		return getBean();
	}
}